<h1 class="title"><%= @task.subject %></h1>

<div id="task_description"><%= to_html(@task.description) %></div>

<div id="task_meta">
<table class="tabular details multiple">
 <tr class="header">
  <th>Basics</th>
  <th></th>
 </tr> 
 <tr class="even_row">
  <td><strong>Id</strong></td>
  <td><%= @task.task_id %></td>
 </tr>
 <tr>
  <td><strong>Status</strong></td>
  <td><%= @task.status.name %></td>
 </tr>
 <tr class="even_row">
  <td><strong>Estimated Time</strong></td>
  <td><%= @task.estimated_time %> min</td>
 </tr>
 <tr>
  <td><strong>Time Worked</strong></td>
  <td><%= @task.time_worked %> min</td>
 </tr>
 <tr class="even_row">
  <td><strong>Time Left</strong></td>
  <td><% time_left = @task.estimated_time - @task.time_worked %><% if time_left >= 0 %><%= time_left %> min<% else %>0<% end %></td>
 </tr>
 <tr>
  <td><strong>Priority</strong></td>
  <td><%= @task.priority %>/10</td>
 </tr>
 <tr class="even_row">
  <td><strong>Project</strong></td>
  <td><%= link_to @task.project.name, {:controller => 'project', :action => 'show', :id => @task.project_fk }%></td>
 </tr>
</table>

<table class="tabular details multiple">
 <tr class="header">
  <th>People</th>
  <th></th>
 </tr>
 <tr class="even_row">
  <td><strong>Owner</strong></td>
  <td><% if @task.user %><%= link_to @task.user.username, {:controller => 'user', :action => 'show', :id => @task.owner } %><% else %> Nobody <% end %></td>
 </tr>
 <tr>
  <td><strong>Requestor</strong></td>
  <td><%= @task.requestor %></td>
 </tr>
</table>

<table class="tabular details multiple">
 <tr class="header">
  <th>Dates</th>
  <th></th>
 </tr>
 <tr class="even_row">
  <td><strong>Created</strong></td>
  <td><%= @task.created.strftime('%a, %B %d %Y, %H:%M:%S') %></td>
 </tr>
 <tr>
  <td><strong>Closed</strong></td>
  <td><% if @task.status.name == 'closed' %><% last_date = @task.comments.find(:first, :order => 'added desc') %>
         <% if last_date != nil %><%= last_date.added.strftime('%a, %B %d %Y, %H:%M:%S') %><% end %>  
	 <% end %>
 </tr>
</table>
</div>

<div id="comments">
 <% odd = 1 %>
 <% for comment in @comments %>
  <div class="comment<% if odd == 1 %> odd_row<% odd = 0 %><% else %> even_row<% odd = 1 %><% end %>">
   <div class="user"><%= link_to comment.user.username, {:controller => 'user', :action => 'show', :id => comment.user_fk } %></div>
   <div class="subject"><%= comment.subject %></div>
   <div class="worked"><% if comment.time_worked != 0 %><%= comment.time_worked %> min <% end %></div>
   <div class="transaction"><%= comment.transaction %></div>
   <div class="date"><%= comment.added.strftime('%a, %B %d %Y, %H:%M:%S') %></div>
   <div class="content"><%= to_html(comment.content) %></div>
  </div>
 <% end %>
</div>


